package day15.test04;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author Xiao
 * @date 2021/8/9
 */
public class Server04 {
    /**
     * 4. 使用TCP完成简单的数据传输
     *     发送端发送，接收端接收
     */
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(12121);
        Socket socket = ss.accept();
        InputStream is = socket.getInputStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String s;
        while ((s = br.readLine()) != null) {
            System.out.println(s);
        }
        socket.close();
        ss.close();
    }
}
